"""
weibiapi.py
封装第三方微博接口
"""

class OAuthWeiBoAPI:
    def __init__(self,app_key,app_secret,redirect_uri):
        self.app_key = app_key
        self.app_secret = app_secret
        self.redirect_uri = redirect_uri

    def get_grant_url(self):
        """
        获取微博授权登录页地址[依据接口文档]
        """
        return f"https://api.weibo.com/oauth2/authorize?client_id={self.app_key}" \
            f"&redirect_uri={self.redirect_uri}&response_type=code"

if __name__ == '__main__':
    config = {
        "app_key":"3713320668",
        "app_secret":"fd641d07584a7ee094cec19356b82a90",
        "redirect_uri":"http://localhost:7000/dadashop/templates/callback.html",
    }
    weibo_api = OAuthWeiBoAPI(**config)
    print(weibo_api.get_grant_url())



